package cn.liontalk.ObserverPattern;

/**
 * Created by ZhouZhe on 2018/5/19.
 */
public class CurrentConditionDisplay implements Observer,DisplayElement {

    private float temperature;

    private float humidity;

    private Subject weatherData;



    public CurrentConditionDisplay(Subject weatherData){
        this.weatherData = weatherData;
        weatherData.registerObserver(this);

    }


    @Override
    public void display() {
        System.out.println("CurrentConditionDisplay{" +
                "temperature=" + temperature +
                ", humidity=" + humidity +
                ", weatherData=" + weatherData +
                '}');
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temperature = temp;
        this.humidity = humidity;
        display();
    }
}
